package eco2automotive.gui.components;
import javax.swing.*;
import java.awt.*;

/**  
  * Panel, display information TX/RX
  * @version 1.0
 * @author Fco Javier Sanchez Esparza
 */
public class Panel_TxRx  extends JPanel {  
    private JTextArea TX; 
    private JTextArea RX; 
    private JScrollPane TXScroll;
    private JScrollPane RXScroll;    
    
    /**
     * This panel contains the RX TextArea and Tx TextArea to display the data
     * to send and the data recived from the interface control.
     */
    public Panel_TxRx(){                  

      TX= new JTextArea("TX>");
      RX= new JTextArea("RX>");
      TX.setEditable(false);
      RX.setEditable(false);
      //setLayout(new FlowLayout());
      RX.setColumns(50);
      TX.setColumns(50);
      
      TXScroll = new JScrollPane(TX);
      RXScroll = new JScrollPane(RX);
      
      TXScroll.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
      TXScroll.setBorder(new javax.swing.border.TitledBorder("TX Data"));      
      RXScroll.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
      RXScroll.setBorder(new javax.swing.border.TitledBorder("RX Data"));      

      this.setLayout(new GridLayout(2,1,2,2));
      this.add(TXScroll);
      this.add(RXScroll);
     
    }
    /**
     * Update the rx information
     * @param rxinfo
     */
    public void updateRX_INFO(String rxinfo){this.RX.setText("\n"+rxinfo); this.updateUI();}
    /**
     * Update the tx information
     * @param txinfo
     */
    public void updateTX_INFO(String txinfo){this.TX.setText("\n"+txinfo);this.updateUI();}

    
}
